<?
    class ComplexException extends Exception {
        private $_title;
        private $_message;
        function __construct($title,$message) {
            $this->_title = $title;
            $this->_message = $message;
        }
        function Message() { 
            $trace = $this->getTrace();
            $first = array_pop($trace);
//            $trace = array_reverse($trace,true);
            
            $buf .= $this->_message; 
            $buf .= "<br /><br />";
            $buf .= "<h4>Exception Details:</h4>";
            $buf .= $first['file'] . ":<b>" . $first['line'] . "</b>";
            $buf .= "<br />";
            $buf .= "<br />";
            $buf .= "<h4>Stack Trace:</h4>";
            
			foreach ($trace as $count => $call) {
				$buf .= $call['file'] . ":<b>" . $call['line'] . " @ " . (isset($call['class']) ? $call['class'] . $call['type'] : '') . $call['function'] . "()</b><br />";
			}
            return $buf;
        }
        function Title() { return $this->_title; }
    }
    
    function SimpleExceptionHandler($exception) {
    	if (method_exists($exception,"Title")) {
	        FatalMessage::Show($exception->Title(),$exception->Message());
	    }
	    else die($exception->getMessage());
    }
    
    set_exception_handler("SimpleExceptionHandler");
?>